#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

void solve() {
	int n; cin >> n;
	vector<int> a(n + 10, 2e9);
	for (int i = 1; i <= n; i++) cin >> a[i];
	int cnt = 0, pos = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] != a[i - 1]) {
			pos = i - 1;
		}
		if (a[pos] > a[i] && a[i] < a[i+1]) cnt++;
	}
	cout << (cnt == 1 ? "YES" : "NO") << endl;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}